package io.cp.connector.api.entity;


import io.cp.connector.api.constant.SystemEnum.ResultCode;

public class MessageResult {
	
	private Object data;
	private int code;
	private String message;
	
	private MessageResult() {
	}
	private MessageResult( ResultCode obj ){
		this.code = obj.getCode();
		this.message = obj.getMsg();
	}
	private MessageResult( ResultCode obj, Object data){
		this.code = obj.getCode();
		this.message = obj.getMsg();
		this.data = data;
	}
	
	public static MessageResult success(){
		return new MessageResult( ResultCode.SUCCESS );
	}
	
	public static MessageResult success( Object data ){
		return new MessageResult( ResultCode.SUCCESS , data );
	}
	
	public static MessageResult error( ResultCode obj ){
		return new MessageResult( obj );
	}
	public Object getData() {
		return data;
	}
	public int getCode() {
		return code;
	}
	public String getMessage() {
		return message;
	}
	
}
